<template>
	<view class="box">
		<button @click="back" style="position: fixed;bottom: 20px;right: 20px;">暂不登录</button>
		<button open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber"
			style="position: fixed;bottom: 20px;">登录</button>
	</view>
</template>

<script>
	import WebAPI from "../../api"
	export default {
		data() {
			return {

			};
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			onGetPhoneNumber(e) {
				const that = this
				uni.getStorage({
					key: "token",
					success(res) {
						uni.request({
							url: WebAPI.getUserPhone,
							method: 'POST',
							data: {
								wxCode: e.detail.code,
							},
							header: {
								Authorization: "Bearer:" + res.data // 修改这里的连接方式
							},
							success: (res) => {
								console.log(res);
								that.isLogin = true
								uni.setStorage({
									key: "token",
									data: res.data.data.token
								})
								uni.setStorage({
									key: "hasPhone",
									data: res.data.data.hasPhone
								})
							},
						});
					}
				})
			},
		}
	}
</script>

<style lang="scss">

</style>